#import <Foundation/Foundation.h>

#import "PIObject.h"


enum kPIEventAvailabilityType {
    kPIEventAvailabilityNotSupported = -1,
    kPIEventAvailabilityOutOfOffice = 0,
    kPIEventAvailabilityBusy,
    kPIEventAvailabilityFree,
    kPIEventAvailabilityTentative,
    kPIEventAvailabilityUnavailable
};

enum PIEventStatusType {
    PIEventStatusTypeNone = 0,
    PIEventStatusTypeConfirmed,
    PIEventStatusTypeTentative,
    PIEventStatusTypeCancelled
};

@class CLLocation;


@interface PIEvent : PIObject
{
    NSString* rootKey;
    
    NSString* location;
    CLLocation* coordinates;
    BOOL coordinatesSet;

    NSString* sectionTitle;
    NSArray* sectionDetails;
    NSInteger sectionStartInterval;
    NSInteger sectionEndInterval;
    
    NSDate* endDate;
    NSTimeInterval endDateRaw;
    BOOL allDay;

    BOOL reminderInteract;
    
    BOOL invitation;

    NSDate* rangeStartDate;
    NSDate* rangeEndDate;

    kPIEventAvailabilityType availability;
    PIEventStatusType status;
    
    NSString* organiser;
    BOOL hasAttendees;
    NSArray* attendees;

    NSDate* firstAlarm;
    NSDate* nextAlarm;
}

@property (readonly) NSString* rootKey;
@property (readonly) NSString* location;
@property (readonly) CLLocation* coordinates;

@property (retain) NSString* sectionTitle;
@property (retain) NSArray* sectionDetails;
@property (assign) NSInteger sectionStartInterval;
@property (assign) NSInteger sectionEndInterval;

@property (retain) NSDate* endDate;
@property (readonly) NSTimeInterval endDateRaw;
@property (assign, getter=isAllDay) BOOL allDay;
@property (assign, getter=isInvitation) BOOL invitation;

@property (retain) NSDate* rangeStartDate;
@property (retain) NSDate* rangeEndDate;

@property (readwrite, assign) kPIEventAvailabilityType availability;
@property (readwrite, assign) PIEventStatusType status;

@property (retain) NSDate* firstAlarm;
@property (retain) NSDate* nextAlarm;

@property (readwrite, assign) BOOL hasAttendees;
@property (retain) NSArray* attendees;
@property (retain) NSString* organiser;

@property (assign, getter=isReminderInteract) BOOL reminderInteract;


+ (PIEvent*)nativeEventWithKey:(NSString*)newKey version:(NSInteger)version title:(NSString*)newTitle icon:(NSString*)newIcon location:(NSString*)newLocation startDate:(NSDate*)newStart startDateRaw:(NSTimeInterval)newStartRaw endDate:(NSDate*)newEnd endDateRaw:(NSTimeInterval)newEndRaw allDay:(BOOL)newAllDay calendar:(NSString*)newCalendar calendarIcon:(NSString*)newCalIcon calendarColor:(UIColor*)newCalColor;

+ (PIEvent*)piEventWithKey:(NSString*)newKey rootKey:(NSString*)newRootKey version:(NSInteger)version title:(NSString*)newTitle icon:(NSString*)newIcon location:(NSString*)newLocation startDate:(NSDate*)newStart startDateRaw:(NSTimeInterval)newStartRaw endDate:(NSDate*)newEnd endDateRaw:(NSTimeInterval)newEndRaw allDay:(BOOL)newAllDay calendar:(NSString*)newCalendar calendarIcon:(NSString*)newCalIcon calendarColor:(UIColor*)newCalColor;

- (id)copyInstance:(NSInteger)instance;
- (id)copyWithZone:(NSZone *)zone;
- (id)copyWithZone:(NSZone *)zone instance:(NSInteger)instance;

- (BOOL)hasDetails;

- (NSString*)shortDescription;

@end


@interface NSArray (PIEvent)

- (NSArray*)piEventsForRootKey:(NSString*)key;

@end
